package Operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class BorrwoedOperation implements IOOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书！");
        Scanner in = new Scanner(System.in);
        System.out.println("请输入你要借阅书籍的名称:");
        String name = in.nextLine();

        int currentSize = bookList.getUsedSize();
        int i = 0;
        for (; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)) {
                book.setBorrowed(true);
                System.out.println("借阅成功!");
                System.out.println(book);
                return;
            }
        }
        if (i == currentSize) {
            System.out.println("没有你要找的图书!");
            return;
        }

    }
}
